﻿using FluentAssertions;
using Xunit;

namespace Sustainalytics.ScreeningTool.Synchronization.Tests.Extensions.StringExtensionsTests
{
    public class EnsureEndsWithPeriod_Should
    {
        [Fact]
        public void return_empty_string_for_null_value() => ((string)null).EnsureEndsWithPeriod().Should().Be("");

        [Fact]
        public void return_empty_string_for_empty_value() => "".EnsureEndsWithPeriod().Should().Be("");

        [Fact]
        public void return_empty_string_for_white_space_value() => "   ".EnsureEndsWithPeriod().Should().Be("");

        [Fact]
        public void return_trimmed_value_ending_with_period_when_value_does_not_end_in_period()
            => " bla bla ".EnsureEndsWithPeriod().Should().Be("bla bla.");

        [Fact]
        public void return_trimmed_value_when_value_ends_in_period()
            => " bla bla. ".EnsureEndsWithPeriod().Should().Be("bla bla.");

        [Fact]
        public void return_trimmed_values_ending_with_period_for_collections_of_values()
            => new[] { null, "", "   ", " bla bla ", "bla bla. " }.EnsureEndsWithPeriod().Should().BeEquivalentTo(
                new[] { "", "", "", "bla bla.", "bla bla." }, options => options.WithStrictOrdering());
    }
}
